<template>
  <div style="padding: 10px">
    <tl-ref-user ref="refUser" :singleSelect="true" dataType="code" @confirm="confirm" :isDisplayDefaultElement="false">
      <template>
        <el-button type="primary" @click="clickRefUser" :disabled="disabled">选择交接人</el-button>
      </template>
    </tl-ref-user>
    <el-table class="tl-table" ref="mainTable" :height="350" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
      <el-table-column type="selection" width="55px" fixed="left"> </el-table-column>
      <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
      <el-table-column prop="projectname" label="待交接项目" min-width="180px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="projectcode" label="项目编号" width="150px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="dispprojectlevel" label="项目级别" width="100px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="dispprojectstate" label="项目阶段" width="150px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
			<el-table-column prop="newusername" label="交接人" width="150px" align="center" header-align="center"></el-table-column>
      <el-table-column prop="newusercode" label="交接人工号" width="150px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
import { validateNull } from '@tapui/utils/validate'
export default {
  name: 'mpmProjectChangeManagerInfo',
  mixins: [mixin_list],
  components: { },
  data() {
    return {
      description: '项目交接详情-列表查询',
      urlPrefix: '/mpm/projectChangeManagerInfo/',
      url: {
        // queryCodeList: '/mpm/projectChangeManagerInfo/dataCodeList'
        checkSameProvinceStaff: '/mpm/projectChangeManager/checkSameProvinceStaff'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      },
      pageInfo: {
        currentPage: 1, // 当前页面
        pageSize: 1000, // 每页记录数
        pageSizes: ['10', '50', '100'],
        totalCount: 0 // 总数
      },
      isQueryOnCreated: false
    }
  },
  props: {
    model: {
      type: Object,
      default: () => {}
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    beforeLoadData() {
      if (!this.model.id) {
        return false
      }
      this.queryParam.qry_parentid = this.model.id
      return true
    },
    confirm(selectedRows) {
      const param = { projectmanagercode: selectedRows[0].code, usercode: this.user.code }
      getAction(this.url.checkSameProvinceStaff, param).then(res => {
        if (res.success) {
          this.datas.forEach(item => {
            if (this.selectedRowKeys.indexOf(item.id) > -1) {
              item.newusercode = selectedRows[0].code
              item.newusername = selectedRows[0].name
            }
          })
          this.$refs.mainTable.clearSelection()
        } else {
          this.$tap.alert(res.message, 'warning')
        }
      })
    },
    clickRefUser() {
      if (validateNull(this.selectedRowKeys)) {
        this.$tap.alert('请先勾选项目！', 'warning')
        return false
      }
      this.$refs.refUser.openRefDialog()
    }
  }
}
</script>

<style scoped></style>

